//
//  ZCAddressViewModel.m
//  ZCJZ
//
//  Created by sujeking on 2019/2/28.
//  Copyright © 2019年 jeking. All rights reserved.
//

#import "ZCAddressViewModel.h"
#import "SKBaseWebService.h"
#import <MJExtension.h>

@implementation ZCAddressViewModel

+ (void)fetchMyAddressListWithKeywords:(NSString *)keywords
                              complete:(void (^)(ZCErrorCode status, NSString *message,id data))block {
    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
    [parameters setValue:keywords forKey:@"keywords"];
    [SKBaseWebService getRequest:@"/v1/member-address/list" parameters:parameters progress:nil success:^(ZCErrorCode status, NSString *msg, NSDictionary *data) {
        block(status,msg,data);
    } failure:^(ZCErrorCode status, NSString *msg, NSDictionary *data) {
        block(status,msg,nil);
    }];
}

+ (void)fetchAreaListWithPid:(NSString *)pid
                    complete:(void (^)(ZCErrorCode status, NSString *message,id data))block {
    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
    [parameters setValue:pid forKey:@"pid"];
    [SKBaseWebService getRequest:@"/v1/area/list" parameters:parameters progress:nil success:^(ZCErrorCode status, NSString *msg, NSDictionary *data) {
        block(status,msg,data);
    } failure:^(ZCErrorCode status, NSString *msg, NSDictionary *data) {
        block(status,msg,nil);
    }];
}

+ (void)fetchPayAreaListWithPid:(NSString *)pid
                    complete:(void (^)(ZCErrorCode status, NSString *message,id data))block {
    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
    [parameters setValue:pid forKey:@"pid"];
    [SKBaseWebService getRequest:@"/v1/pay/bank-area" parameters:parameters progress:nil success:^(ZCErrorCode status, NSString *msg, NSDictionary *data) {
        block(status,msg,data);
    } failure:^(ZCErrorCode status, NSString *msg, NSDictionary *data) {
        block(status,msg,nil);
    }];
}

+ (void)saveAreaListWithAddress:(id)model
                        complete:(void (^)(ZCErrorCode status, NSString *message,id data))block {

    NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithDictionary:[model mj_keyValues]];
    [SKBaseWebService postRequest:@"/v1/member-address/save" parameters:parameters progress:nil success:^(ZCErrorCode status, NSString *msg, NSDictionary *data) {
        block(status,msg,data);
    } failure:^(ZCErrorCode status, NSString *msg, NSDictionary *data) {
        block(status,msg,nil);
    }];
}

+ (void)removeAddressWithDict:(NSDictionary *)dict
                     complete:(void (^)(ZCErrorCode status, NSString *message,id data))block {
    NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithDictionary:dict];
    [SKBaseWebService getRequest:@"/v1/member-address/del" parameters:parameters progress:nil success:^(ZCErrorCode status, NSString *msg, NSDictionary *data) {
        block(status,msg,data);
    } failure:^(ZCErrorCode status, NSString *msg, NSDictionary *data) {
        block(status,msg,nil);
    }];
}


@end
